home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9475 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: vela.acs.oakland.edu!jggoslin
  2. From: jggoslin@vela.acs.oakland.edu (Monument)
  3. Newsgroups: comp.lang.c
  4. Subject: Passing by reference and Returning structures
  5. Date: 10 Mar 1996 19:55:23 GMT
  6. Organization: Oakland University, Rochester, Michigan, U.S.A.
  7. Message-ID: <4hvc3b$avn@news2.acs.oakland.edu>
  8. NNTP-Posting-Host: vela.acs.oakland.edu
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. I'm a mid level C programmer, not too advanced but not too green
  12. either.  I have a question about a program I am writing for a unix box
  13. running OSF/1.
  14.  
  15. I have to send a matrix of unknown size to a function, and return a
  16. filled structure.  I don't have to change the matrix at all, and the
  17. buffer will be completely filled by the matrix.
  18.  
  19. My question is, what does the return for a structure look like.  I
  20. would assume the function prototype would look something like:
  21.  
  22. my_struct my_function(int matrix[])
  23.  
  24. and the call would be something like
  25.  
  26. structure=my_function(matrix)
  27.  
  28. where my_struct is the structure type and matrix is the variable size
  29. matrix.  However, when I tried just such a setup it didn't work, gave
  30. me a whole mess of errors.  If anyone has any ideas(a missing keyword,
  31. missing ref/deref operators, etc) please let me know.  I need to
  32. change my_struct but not matrix, so feel free to change around the
  33. order and whatnot of the function prototype(ie if you just want it to
  34. return a void, etc)
  35.  
  36. Thanx in advance
  37.  
  38.  ----------------------------------------------------------------------------
  39. |          Jeff Goslin - Monument           | "Oh Bentson, you are so        |
  40. |      jggoslin@vela.acs.oakland.edu        |  mercifully free from the      |
  41. |                                           |  ravages of intellect."        |
  42. | http://www.acs.oakland.edu/links/jggoslin |   --Evil, The Time Bandits     |
  43.  ----------------------------------------------------------------------------
  44. |   how come everyone elses religion is a cult but your cult is a religion   |
  45.  ----------------------------------------------------------------------------
  46.  
  47.